<#include '/admin/header.html' >
<style>
.admin-main .layui-tab{
	background-color: white;
}

.admin-main .layui-tab-content .layui-tab-item{
	height: auto;
	min-width: 384px;
}
</style>
<div class="admin-main" >
	<form action="" class="layui-form layui-form-pane" id="settingForm" >
		<div class="layui-tab layui-tab-card" >
			<ul class="layui-tab-title">
				<#list tabs as tab>
					<li tabid="${tab.order}" <#if tab.order==0>class="layui-this"</#if> >${tab.tabTitle}</li>
				</#list>
			</ul>
			<div class="layui-tab-content" style="min-height: 1300px;margin-bottom: 50px;">
				<#list tabs as html>
					<div class="layui-tab-item <#if html.order==0>layui-show</#if>">${html.tabHtml}</div>
				</#list>
			</div>
		</div>
		
		<div class="save-div">
			<a class="layui-btn layui-btn-normal" lay-submit lay-filter="systemBtn">立即保存</a>
		</div>
		
	</form>
</div>

<script>

var index=parent.parent.layer.index;

//注意：选项卡 依赖 element 模块，否则无法进行功能性操作
layui.use(['element','upload','form'], function() {
	var element = layui.element();
	var upload = layui.upload();
	var form = layui.form();
/* 页面进行渲染 */
	form.render(); 
	
	//监听提交
	form.on('submit(systemBtn)', function(data){
		var options = {
			url : "${ctx}/core/admin/setting/save.do?ajax=yes",
			type : "POST",
			dataType : 'json',
			success : function(result) {
				if (result.result == 1) {
					layer.msg(result.message, {icon: 6}); 
				}else{
					layer.msg(result.message, {icon: 5}); 
				}
			},
			error : function(e) {
				layer.msg("出现错误 ，请重试", {icon: 5}); 
			}
		};
		$('#settingForm').ajaxSubmit(options);
		return false;
	});
	
	//监听，系统设置—增值组件的开启
	form.on('radio(check)', function(data){
		var $this  = $(data.elem);
		var id =$this.attr("clz");
		$.ajax({
			url:'check-component/exist.do',
			data:'id='+id,
			dataType:"json",
			success:function(json){
				if(json.result==0){
					layer.msg("此组件不存在，请您购买安装后再启用", {icon: 5}); 
					$this.removeAttr("checked");
					$this.siblings("[value=0]").attr("checked","checked")
					form.render('radio');	//重新渲染radio
				}
			},
			error:function(){
				layer.msg("出现意外错误", {icon: 5}); 
			}
		});
		
	});
	
});

</script>

<#include '/admin/footer.html' >
